﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace Third{
    public class Analytics : SingletonMono<Analytics>
    {
       private TDGAAccount account;
        // Use this for initialization
        void Start()
        {
            InitTalkingData();
        }

        private void InitTalkingData()
        {
#if UNITY_IPHONE
#if UNITY_5
		UnityEngine.iOS.NotificationServices.RegisterForNotifications(
			UnityEngine.iOS.NotificationType.Alert |
			UnityEngine.iOS.NotificationType.Badge |
			UnityEngine.iOS.NotificationType.Sound);
#else
		UnityEngine.iOS.NotificationServices.RegisterForNotifications(
			UnityEngine.iOS.NotificationType.Alert |
			UnityEngine.iOS.NotificationType.Badge |
			UnityEngine.iOS.NotificationType.Sound);
#endif
#endif
            TalkingDataGA.OnStart("89FD8D03F39541A3A66BA16DA07BE7FF", "NoChannel");
            
        }

        public TDGAAccount GetAccount(string user)
        {
            if(account == null)
                account = TDGAAccount.SetAccount(user);
            return account;
        }

        public void SetReward(string reward)
        {
         //   TDGAVirtualCurrency.OnReward(100, "reason");
        }

        public void SetLevel(string level)
        {
// 
//             if(account != null)
//             {
//                 account.SetLevel(int.Parse(level));
//             }
        }

        public void SetGameServer(string serverId)
        {
//             if (account != null)
//                 account.SetGameServer(serverId);
        }

        public void EnterPage(string page)
        {
       //     TDGAMission.OnBegin(page);
        }

        public void LeavePage(string page)
        {
        //    TDGAMission.OnCompleted(page);
        }

        public void SendEvent(string keyEvent, Dictionary<string, object> dic)
        {
         //   TalkingDataGA.OnEvent(keyEvent, dic);
        }

        void OnDestroy()
        {
            TalkingDataGA.OnEnd();
            Debug.Log("onDestroy");
        }
    }

}
